<% var obj = {pageTitle:"公寓管理系统"} %>
{{include "../header.html" obj}}
<script src="//g.alicdn.com/dingding/dinglogin/0.0.5/ddLogin.js"></script>
<div class=" container">
    {{include "../pageHeader.html" obj}}
    <div class="col-md-4 col-md-offset-4">
        <ul class="nav nav-tabs nav-justified" style="width:365px;">
            <li class="active"><a href="#paneLogin" data-toggle="tab">扫码登录</a></li>
            <li><a href="#paneRegister" data-toggle="tab">账号登陆</a></li>
        </ul>
        <div class="tab-content" style="margin-top:20px">
            <div class="tab-pane fade in active" id="paneLogin">
                <div id="login_container">
                </div>
            </div>
            <div class="tab-pane" id="paneRegister">
                <form class=" form-horizontal" method="POST" action="/admin/checkLogin" enctype="application/x-www-form-urlencoded">
                    <div class=" form-group">
                        <div class=" input-group">
                            <div class=" input-group-addon">
                                <span class=" glyphicon glyphicon-user"></span>
                            </div>
                            <input type="text" class=" form-control" data-tip="账号" name="userName">
                        </div>
                    </div>
                    <div class=" form-group">
                        <div class=" input-group">
                            <div class=" input-group-addon">
                                <span class=" glyphicon glyphicon-lock"></span>
                            </div>
                            <input type="password" class=" form-control" data-tip="密码" name="userPwd">
                        </div>
                    </div>
                    <div class=" form-group">
                        <div class=" input-group">
                            <div class=" input-group-addon">
                                <span class=" glyphicon glyphicon-th-list"></span>
                            </div>
                            <select name="userType" id="" class=" form-control">
                                <option value="">--请选择用户类型--</option>
                                <option value="超级管理员">超级管理员</option>
                                <option value="宿舍管理员">宿舍管理员</option>
                                <option value="学生">学生</option>
                            </select>
                        </div>
                    </div>
                    <div class=" form-group">
                        <button type="submit" class=" btn btn-primary btn-block btn-submit-loading">登陆</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<style type="text/css">
    body {
        background-image: url("../../public/images/loginbg.jpg");
        background-size: 100% 100%;
        background-attachment: fixed;
        display: flex;
        justify-content: center;
        align-items: center;
        position: fixed;
        top: 0px;
        left: 0px;
        right: 0px;
        bottom: 0px;
    }

    #paneRegister {
        width: 365px;
        height: 400px;
    }

    .page-header {
        border-bottom: none;
    }
</style>
<script>
    $(function () {
        $(".form-control").inputTips();
        var goto = "https://oapi.dingtalk.com/connect/oauth2/sns_authorize?appid=dingoa7dutmgycytbiz51a&response_type=code&scope=snsapi_login&state=STATE&redirect_uri=http://www.ricardolsw.com/admin/scanCode";
        var obj = DDLogin({
            id: "login_container",//这里需要你在自己的页面定义一个HTML标签并设置id，例如<div id="login_container"></div>或<span id="login_container"></span>
            goto: encodeURIComponent(goto),
            width: "365",
            height: "400"
        });
        var hanndleMessage = function (event) {
            var origin = event.origin;
            console.log("origin", event.origin);
            if (origin == "https://login.dingtalk.com") { //判断是否来自ddLogin扫码事件。
                var loginTmpCode = event.data; //拿到loginTmpCode后就可以在这里构造跳转链接进行跳转了
                console.log("loginTmpCode", loginTmpCode);
                var url = "https://oapi.dingtalk.com/connect/oauth2/sns_authorize?appid=dingoa7dutmgycytbiz51a&response_type=code&scope=snsapi_login&state=STATE&redirect_uri=http://www.ricardolsw.com/admin/scanCode&loginTmpCode=" + loginTmpCode;
                location.href = url;
            }

        };

        if (typeof window.addEventListener != 'undefined') {
            window.addEventListener('message', hanndleMessage, false);
        } else if (typeof window.attachEvent != 'undefined') {
            window.attachEvent('onmessage', hanndleMessage);
        }
    })
</script>
{{include "../footer.html"}}